<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>TCP协议：滑动窗口与拥塞控制的协同之道</title>
    <link href="https://cdn.staticfile.org/font-awesome/6.4.0/css/all.min.css" rel="stylesheet">
    <link href="https://cdn.staticfile.org/tailwindcss/2.2.19/tailwind.min.css" rel="stylesheet">
    <link href="https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;500;600;700&family=Noto+Sans+SC:wght@300;400;500;700&display=swap" rel="stylesheet">
    <script src="https://cdn.jsdelivr.net/npm/mermaid@latest/dist/mermaid.min.js"></script>
    <style>
        body {
            font-family: 'Noto Sans SC', Tahoma, Arial, Roboto, "Droid Sans", "Helvetica Neue", "Droid Sans Fallback", "Heiti SC", "Hiragino Sans GB", Simsun, sans-serif;
            background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
            min-height: 100vh;
        }
        
        .hero-gradient {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        }
        
        .card-hover {
            transition: all 0.3s ease;
            border: 2px solid transparent;
        }
        
        .card-hover:hover {
            transform: translateY(-5px);
            box-shadow: 0 20px 40px rgba(0,0,0,0.1);
            border-color: #667eea;
        }
        
        .section-title {
            position: relative;
            padding-left: 20px;
        }
        
        .section-title::before {
            content: '';
            position: absolute;
            left: 0;
            top: 50%;
            transform: translateY(-50%);
            width: 4px;
            height: 30px;
            background: linear-gradient(to bottom, #667eea, #764ba2);
            border-radius: 2px;
        }
        
        .feature-icon {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            -webkit-background-clip: text;
            -webkit-text-fill-color: transparent;
        }
        
        .content-card {
            backdrop-filter: blur(10px);
            background: rgba(255, 255, 255, 0.95);
        }
        
        .highlight-text {
            background: linear-gradient(to right, #667eea, #764ba2);
            -webkit-background-clip: text;
            -webkit-text-fill-color: transparent;
            font-weight: 600;
        }
        
        .mermaid {
            display: flex;
            justify-content: center;
            margin: 2rem 0;
        }
        
        .first-letter {
            float: left;
            font-size: 4rem;
            line-height: 3rem;
            padding-right: 0.5rem;
            font-weight: 700;
            color: #667eea;
            font-family: 'Noto Serif SC', serif;
        }
        
        @keyframes fadeInUp {
            from {
                opacity: 0;
                transform: translateY(30px);
            }
            to {
                opacity: 1;
                transform: translateY(0);
            }
        }
        
        .animate-fadeInUp {
            animation: fadeInUp 0.8s ease-out;
        }
        
        .comparison-grid {
            display: grid;
            grid-template-columns: 1fr 1fr;
            gap: 2rem;
            margin: 2rem 0;
        }
        
        @media (max-width: 768px) {
            .comparison-grid {
                grid-template-columns: 1fr;
            }
        }
    </style>
</head>
<body>
    <!-- Hero Section -->
    <section class="hero-gradient text-white py-20 px-6">
        <div class="max-w-6xl mx-auto text-center animate-fadeInUp">
            <h1 class="text-5xl md:text-6xl font-bold mb-6">
                TCP协议的双重保障
            </h1>
            <p class="text-xl md:text-2xl mb-8 opacity-90">
                深入理解滑动窗口与拥塞控制的协同机制
            </p>
            <div class="flex justify-center space-x-8 text-lg">
                <div class="flex items-center">
                    <i class="fas fa-window-restore mr-2"></i>
                    <span>流量控制</span>
                </div>
                <div class="flex items-center">
                    <i class="fas fa-network-wired mr-2"></i>
                    <span>拥塞控制</span>
                </div>
                <div class="flex items-center">
                    <i class="fas fa-shield-alt mr-2"></i>
                    <span>网络稳定</span>
                </div>
            </div>
        </div>
    </section>

    <!-- Introduction Section -->
    <section class="py-16 px-6">
        <div class="max-w-4xl mx-auto">
            <div class="content-card rounded-2xl shadow-xl p-10">
                <p class="text-lg leading-relaxed text-gray-700">
                    <span class="first-letter">滑</span>动窗口和拥塞控制是 TCP 协议中两种不同的机制，各自解决不同的问题。虽然滑动窗口机制在流量控制方面发挥了重要作用，但拥塞控制机制仍然是必不可少的。滑动窗口主要用于流量控制，确保数据在发送端和接收端之间的流动不会造成接收端缓冲区溢出；而拥塞控制则关注于网络整体的健康和性能，防止因网络过载导致的拥塞。两者共同工作，确保了 TCP 协议在不同网络条件下的高效和稳定。
                </p>
            </div>
        </div>
    </section>

    <!-- Visual Comparison -->
    <section class="py-16 px-6 bg-gray-50">
        <div class="max-w-6xl mx-auto">
            <h2 class="text-4xl font-bold text-center mb-12 text-gray-800">
                <i class="fas fa-balance-scale feature-icon mr-3"></i>
                核心机制对比
            </h2>
            
            <div class="comparison-grid">
                <div class="card-hover bg-white rounded-xl p-8 shadow-lg">
                    <div class="text-center mb-6">
                        <i class="fas fa-window-restore text-5xl text-purple-600 mb-4"></i>
                        <h3 class="text-2xl font-bold text-gray-800">滑动窗口</h3>
                        <p class="text-gray-600 mt-2">流量控制机制</p>
                    </div>
                    <ul class="space-y-3 text-gray-700">
                        <li class="flex items-start">
                            <i class="fas fa-check-circle text-purple-600 mt-1 mr-3"></i>
                            <span>控制发送端与接收端之间的数据流</span>
                        </li>
                        <li class="flex items-start">
                            <i class="fas fa-check-circle text-purple-600 mt-1 mr-3"></i>
                            <span>防止接收端缓冲区溢出</span>
                        </li>
                        <li class="flex items-start">
                            <i class="fas fa-check-circle text-purple-600 mt-1 mr-3"></i>
                            <span>点对点的流量控制</span>
                        </li>
                    </ul>
                </div>
                
                <div class="card-hover bg-white rounded-xl p-8 shadow-lg">
                    <div class="text-center mb-6">
                        <i class="fas fa-network-wired text-5xl text-indigo-600 mb-4"></i>
                        <h3 class="text-2xl font-bold text-gray-800">拥塞控制</h3>
                        <p class="text-gray-600 mt-2">网络优化机制</p>
                    </div>
                    <ul class="space-y-3 text-gray-700">
                        <li class="flex items-start">
                            <i class="fas fa-check-circle text-indigo-600 mt-1 mr-3"></i>
                            <span>防止网络设备过载</span>
                        </li>
                        <li class="flex items-start">
                            <i class="fas fa-check-circle text-indigo-600 mt-1 mr-3"></i>
                            <span>动态调整数据发送速率</span>
                        </li>
                        <li class="flex items-start">
                            <i class="fas fa-check-circle text-indigo-600 mt-1 mr-3"></i>
                            <span>提高整体网络利用效率</span>
                        </li>
                    </ul>
                </div>
            </div>
        </div>
    </section>

    <!-- Mermaid Diagram -->
    <section class="py-16 px-6">
        <div class="max-w-6xl mx-auto">
            <h2 class="text-4xl font-bold text-center mb-12 text-gray-800">
                <i class="fas fa-project-diagram feature-icon mr-3"></i>
                机制关系图解
            </h2>
            <div class="bg-white rounded-2xl shadow-xl p-8">
                <div class="mermaid">
                    graph TB
                        A[TCP协议] --> B[滑动窗口]
                        A --> C[拥塞控制]
                        
                        B --> D[流量控制]
                        B --> E[防止缓冲区溢出]
                        B --> F[点对点控制]
                        
                        C --> G[网络健康监控]
                        C --> H[动态速率调整]
                        C --> I[防止网络过载]
                        
                        D --> J[接收窗口大小]
                        E --> J
                        
                        G --> K[慢启动]
                        G --> L[拥塞避免]
                        H --> K
                        H --> L
                        
                        style A fill:#667eea,stroke:#fff,stroke-width:3px,color:#fff
                        style B fill:#9f7aea,stroke:#fff,stroke-width:2px,color:#fff
                        style C fill:#9f7aea,stroke:#fff,stroke-width:2px,color:#fff
                </div>
            </div>
        </div>
    </section>

    <!-- Detailed Comparison -->
    <section class="py-16 px-6 bg-gray-50">
        <div class="max-w-5xl mx-auto">
            <h2 class="text-4xl font-bold text-center mb-12 text-gray-800">
                <i class="fas fa-microscope feature-icon mr-3"></i>
                深度对比分析
            </h2>
            
            <div class="space-y-8">
                <!-- 解决不同问题 -->
                <div class="content-card rounded-xl shadow-lg p-8">
                    <h3 class="section-title text-2xl font-bold mb-6 text-gray-800">
                        解决不同问题
                    </h3>
                    <div class="grid md:grid-cols-2 gap-6">
                        <div>
                            <h4 class="font-semibold text-lg mb-3 highlight-text">滑动窗口</h4>
                            <p class="text-gray-700 leading-relaxed">
                                滑动窗口机制解决了发送端和接收端之间的流量控制问题，确保数据可以顺利传输而不会因为接收端处理能力不足而丢失。它主要关注的是点对点的流量控制。
                            </p>
                        </div>
                        <div>
                            <h4 class="font-semibold text-lg mb-3 highlight-text">拥塞控制</h4>
                            <p class="text-gray-700 leading-relaxed">
                                拥塞控制机制解决了因网络负载过重而导致的拥塞问题。这种情况可能会发生在网络中任何位置（如中间路由器或交换机），影响到整个网络的性能。
                            </p>
                        </div>
                    </div>
                </div>

                <!-- 网络瓶颈和容量问题 -->
                <div class="content-card rounded-xl shadow-lg p-8">
                    <h3 class="section-title text-2xl font-bold mb-6 text-gray-800">
                        网络瓶颈和容量问题
                    </h3>
                    <div class="grid md:grid-cols-2 gap-6">
                        <div>
                            <h4 class="font-semibold text-lg mb-3 highlight-text">滑动窗口</h4>
                            <p class="text-gray-700 leading-relaxed">
                                滑动窗口机制无法解决网络中存在的瓶颈或容量问题。例如，如果网络中某个路由器或链路的带宽有限，滑动窗口机制无法直接缓解这种瓶颈所导致的拥塞问题。
                            </p>
                        </div>
                        <div>
                            <h4 class="font-semibold text-lg mb-3 highlight-text">拥塞控制</h4>
                            <p class="text-gray-700 leading-relaxed">
                                拥塞控制机制通过算法（如慢启动、拥塞避免）来动态调整数据传输速率，检测网络的拥塞状态，并在检测到拥塞时减小发送速率，从而缓解网络瓶颈。
                            </p>
                        </div>
                    </div>
                </div>

                <!-- 网络负载变化 -->
                <div class="content-card rounded-xl shadow-lg p-8">
                    <h3 class="section-title text-2xl font-bold mb-6 text-gray-800">
                        网络负载变化
                    </h3>
                    <div class="grid md:grid-cols-2 gap-6">
                        